<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>登录与注册</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            background-color: #f4f4f4;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            margin: 0;
        }

        .form-container {
            background-color: #fff;
            padding: 20px;
            border-radius: 5px;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
            width: 300px;
        }

        .form-group {
            margin-bottom: 15px;
        }

        .form-group label {
            display: block;
            margin-bottom: 5px;
        }

        .form-group input {
            width: 100%;
            padding: 8px;
            border: 1px solid #ccc;
            border-radius: 3px;
        }

        button {
            width: 100%;
            padding: 10px;
            background-color: #007BFF;
            color: #fff;
            border: none;
            border-radius: 3px;
            cursor: pointer;
        }

        button:hover {
            background-color: #0056b3;
        }

        .toggle-btn {
            background-color: #6c757d;
        }

        .toggle-btn:hover {
            background-color: #5a6268;
        }

        .hidden {
            display: none;
        }
    </style>
</head>
<body>
    <div class="form-container">
        <form id="loginForm">
            <h2>登录</h2>
            <div class="form-group">
                <label for="loginUsername">用户名</label>
                <input type="text" id="loginUsername" required>
            </div>
            <div class="form-group">
                <label for="loginPassword">密码</label>
                <input type="password" id="loginPassword" required>
            </div>
            <button type="submit">登录</button>
            <button type="button" class="toggle-btn" onclick="toggleForm('registerForm')">去注册</button>
        </form>

        <form id="registerForm" class="hidden">
            <h2>注册</h2>
            <div class="form-group">
                <label for="registerUsername">用户名</label>
                <input type="text" id="registerUsername" required>
            </div>
            <div class="form-group">
                <label for="registerPassword">密码</label>
                <input type="password" id="registerPassword" required>
            </div>
            <div class="form-group">
                <label for="registerPhone">手机号</label>
                <input type="tel" id="registerPhone" required>
            </div>
            <button type="submit">注册</button>
            <button type="button" class="toggle-btn" onclick="toggleForm('loginForm')">已有账号去登录</button>
        </form>
    </div>

    <script>
        function toggleForm(formId) {
            const loginForm = document.getElementById('loginForm');
            const registerForm = document.getElementById('registerForm');

            if (formId === 'registerForm') {
                loginForm.classList.add('hidden');
                registerForm.classList.remove('hidden');
            } else {
                registerForm.classList.add('hidden');
                loginForm.classList.remove('hidden');
            }
        }
    </script>
</body>
</html>